import { convertToTree } from "../utils/menuUtils";

let meunData = [
  {
    id: 1,
    parentId: null,
    index: "sys",
    title: "系统管理",
    icon: "Setting",
  },
  {
    id: 2,
    parentId: 1,
    index: "equipment",
    title: "设备管理",
    icon: "Tools",
  },
  {
    id: 3,
    parentId: 1,
    index: "contract",
    title: "合同管理",
    icon: "Avatar",
  },
  
];

// let meunList = [
//   {
//     id: 1,
//     parentId: null,
//     index: "sys",
//     title: "系统管理",
//     icon: "Setting",
//     children: [
//       {
//         id: 2,
//         parentId: 1,
//         index: "user",
//         title: "用户管理",
//         icon: "User",
//       },
//       {
//         id: 3,
//         parentId: 1,
//         index: "role",
//         title: "角色管理",
//         icon: "Avatar",
//       },
//       {
//         id: 4,
//         parentId: 1,
//         index: "about",
//         title: "关于",
//         icon: "InfoFilled", // 修改为直接使用导入的图标组件
//       },
//     ],
//   },
//   {
//     id: 5,
//     parentId: null,
//     index: "sys2",
//     title: "系统管理2",
//     icon: "Setting",
//     children: [
//       {
//         id: 6,
//         parentId: 5,
//         index: "user2",
//         title: "用户管理2",
//         icon: "User",
//       },
//       {
//         id: 7,
//         parentId: 5,
//         index: "role2",
//         title: "角色管理2",
//         icon: "Avatar",
//       },
//       {
//         id: 8,
//         parentId: 5,
//         index: "about2",
//         title: "关于2",
//         icon: "InfoFilled", // 修改为直接使用导入的图标组件
//       },
//     ],
//   },
// ];

//获取菜单数据
const getMenuList = (req: any, res: any) => {
  let item = JSON.parse(req.body);
  let meunList = convertToTree(meunData);
  console.log("meunList", meunList);
  return {
    code: 200,
    msg: "登陆成功",
    data: meunList,
  };
};

//获取登录数据
const getLogin = (req: any, res: any) => {
  let item = JSON.parse(req.body);
  let account = item.name;
  let password = item.password;
  if (account === "doaing" && password === "qwe") {
    return {
      code: 200,
      message: "登陆成功",
      data:"eyJhbGciOiJIUzUxMiJ9.eyJ1c2VySWQiOiJhZG1pbiIsInVzZXJOYW1lIjoiYWRtaW4iLCJvcmdDb2RlIjoiMzUwMDAiLCJkZXB0Q29kZSI6IjM1MDAwIiwiYXVkIjoiYWRtaW4iLCJpc3MiOiJhZG1pbiIsImV4cCI6MTU5MzUzNTU5OH0.0pJAojRtT5lx6PS2gH_Q9BmBxeNlgBL37ABX22HyDlebbr66cCjVYZ0v0zbLO_9241FX9-FZpCkEqE98MQOyWw",
    };
  } else {
    return {
      code: 500,
      message: "登陆失败,账号密码不正确",
    };
  }
};

let admininfo = {
  msg: "操作成功",
  code: 200,
  permissions: ["*:*:*"],
  roles: ["admin"],
  user: {
    createBy: "admin",
    createTime: "2024-11-14 15:31:59",
    updateBy: null,
    updateTime: null,
    remark: "管理员",
    params: {
      "@type": "java.util.HashMap",
    },
    userId: 1,
    deptId: 103,
    userName: "zjc",
    nickName: "若依",
    email: "ry@163.com",
    phonenumber: "15888888888",
    sex: "1",
    avatar: null,
    password: "$2a$10$pfdT90lOc4.qnaP830ZCEeRXadn0Jg87X9LnJvQP507dOhwQW3AE2",
    status: "0",
    delFlag: "0",
    loginIp: "124.133.119.32",
    loginDate: "2025-02-12T15:12:33.000+08:00",
    dept: {
      createBy: null,
      createTime: null,
      updateBy: null,
      updateTime: null,
      remark: null,
      params: {
        "@type": "java.util.HashMap",
      },
      deptId: 103,
      parentId: 100,
      ancestors: "0,100",
      deptName: "自己的小程序",
      orderNum: 0,
      leader: "若依",
      phone: null,
      email: null,
      status: "0",
      delFlag: null,
      parentName: null,
      printTitle: null,
      printContent: null,
      toApplet: null,
      children: [],
    },
    roles: [
      {
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        params: {
          "@type": "java.util.HashMap",
        },
        roleId: 1,
        roleName: "超级管理员",
        roleKey: "admin",
        roleSort: 1,
        dataScope: "1",
        menuCheckStrictly: false,
        deptCheckStrictly: false,
        status: "0",
        delFlag: null,
        flag: false,
        menuIds: null,
        deptIds: null,
        permissions: null,
        admin: true,
      },
    ],
    roleIds: null,
    postIds: null,
    roleId: null,
    toApplet: "to_me",
    admin: true,
  },
};

let userinfo = {
  msg: "操作成功",
  code: 200,
  permissions: [
    "carrepair:peijian:add",
    "carrepair:operatelog:query",
    "carrepair:weixiumx:export",
    "carrepair:bxgs:export",
    "carrepair:wxdnr:add",
    "carrepair:bxgs:add",
    "carrepair:wxdnr:export",
    "carrepair:peijianmx:query",
    "carrepair:weixiumx:edit",
    "carrepair:wxdnr:list",
    "carrepair:bxgs:query",
    "carrepair:bxgs:remove",
    "carrepair:peijianmx:add",
    "carrepair:car:query",
    "carrepair:operatelog:add",
    "carrepair:peijian:export",
    "carrepair:peijian:list",
    "carrepair:weixiumx:query",
    "carrepair:peijianmx:list",
    "carrepair:bxgs:list",
    "carrepair:wxdnr:query",
    "carrepair:peijianmx:edit",
    "carrepair:peijian:query",
    "carrepair:car:list",
    "carrepair:operatelog:edit",
    "carrepair:peijian:remove",
    "carrepair:peijianmx:remove",
    "carrepair:car:add",
    "carrepair:car:remove",
    "carrepair:operatelog:export",
    "carrepair:bxgs:edit",
    "carrepair:wxdnr:edit",
    "carrepair:peijian:edit",
    "carrepair:weixiumx:add",
    "carrepair:weixiumx:list",
    "carrepair:car:edit",
    "carrepair:weixiumx:remove",
    "carrepair:operatelog:remove",
    "carrepair:peijianmx:export",
    "carrepair:operatelog:list",
    "carrepair:wxdnr:remove",
    "carrepair:car:export",
  ],
  roles: ["use"],
  user: {
    createBy: "admin",
    createTime: "2024-11-27 17:44:16",
    updateBy: null,
    updateTime: null,
    remark: null,
    params: {
      "@type": "java.util.HashMap",
    },
    userId: 5,
    deptId: 111,
    userName: "zh01",
    nickName: "众辉操作员01",
    email: null,
    phonenumber: null,
    sex: "0",
    avatar: null,
    password: "$2a$10$acKD651zdhDMzC3bwbLf/OqO52DrKyggdPF1HYRvcoQNZBfJ96stm",
    status: "0",
    delFlag: "0",
    loginIp: "111.16.84.182",
    loginDate: "2025-04-09T11:33:41.000+08:00",
    dept: {
      createBy: null,
      createTime: null,
      updateBy: null,
      updateTime: null,
      remark: null,
      params: {
        "@type": "java.util.HashMap",
      },
      deptId: 111,
      parentId: 100,
      ancestors: "0,100",
      deptName: "汶上众辉",
      orderNum: 2,
      leader: null,
      phone: null,
      email: null,
      status: "0",
      delFlag: null,
      parentName: null,
      printTitle: null,
      printContent: null,
      toApplet: null,
      children: [],
    },
    roles: [
      {
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        params: {
          "@type": "java.util.HashMap",
        },
        roleId: 3,
        roleName: "汽车维修行业",
        roleKey: "use",
        roleSort: 0,
        dataScope: "1",
        menuCheckStrictly: false,
        deptCheckStrictly: false,
        status: "0",
        delFlag: null,
        flag: false,
        menuIds: null,
        deptIds: null,
        permissions: [
          "carrepair:peijian:add",
          "carrepair:operatelog:query",
          "carrepair:weixiumx:export",
          "carrepair:bxgs:export",
          "carrepair:wxdnr:add",
          "carrepair:bxgs:add",
          "carrepair:wxdnr:export",
          "carrepair:peijianmx:query",
          "carrepair:weixiumx:edit",
          "carrepair:wxdnr:list",
          "carrepair:bxgs:query",
          "carrepair:bxgs:remove",
          "carrepair:peijianmx:add",
          "carrepair:car:query",
          "carrepair:operatelog:add",
          "carrepair:peijian:export",
          "carrepair:peijian:list",
          "carrepair:weixiumx:query",
          "carrepair:peijianmx:list",
          "carrepair:bxgs:list",
          "carrepair:wxdnr:query",
          "carrepair:peijianmx:edit",
          "carrepair:peijian:query",
          "carrepair:car:list",
          "carrepair:operatelog:edit",
          "carrepair:peijian:remove",
          "carrepair:peijianmx:remove",
          "carrepair:car:add",
          "carrepair:car:remove",
          "carrepair:operatelog:export",
          "carrepair:bxgs:edit",
          "carrepair:wxdnr:edit",
          "carrepair:peijian:edit",
          "carrepair:weixiumx:add",
          "carrepair:weixiumx:list",
          "carrepair:car:edit",
          "carrepair:weixiumx:remove",
          "carrepair:operatelog:remove",
          "carrepair:peijianmx:export",
          "carrepair:operatelog:list",
          "carrepair:wxdnr:remove",
          "carrepair:car:export",
        ],
        admin: false,
      },
    ],
    roleIds: null,
    postIds: null,
    roleId: null,
    toApplet: "众辉",
    admin: false,
  },
};

//获取登录用户信息

const getUserInfo = (req: any, res: any) => {
  // let item = JSON.parse(req.body);
  return {
    code: 200,
    msg: "登陆成功",
    data: userinfo,
  };
};

export default {
  getMenuList,
  getLogin,
  getUserInfo,
};
